<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of EmpleadoDB
 *
 * @author Admin
 */
class Consulta4DB extends CI_Model {

    var $title = '';
    var $content = '';
    var $date = '';

    function __construct() {
        // Call the Model constructor
        parent::__construct();
    }

    function Consulta4() {       
        
         $nulo = NULL;       
        //$this->db->distinct();
          $query = /*$this->db
                ->distinct()
                ->select("bandas.n_banda,bandas.n_miembros")
                ->from("bandas")
                ->from("per_det")
                ->from("atrxj")
                ->join('bandas', 'bandas.n_banda=per_det.n_banda', 'ON') 
                ->join('atrxj', 'atrxj.ci_pd=per_det.ci')  
                //->from("bandas JOIN per_det ON bandas.n_banda=per_det.n_banda JOIN atrxj ON  per_det.ci=atrxj.ci_pd")
                  
                ->group_by(array("bandas.n_banda","bandas.n_miembros","per_det.ci","atrxj.cod_b","atrxj.cod_s"))
                ->having('COUNT(*)>1')
                ->get();*/
                $this->db->query('
                SELECT DISTINCT bandas.n_banda,bandas.n_miembros
                FROM bandas 
                JOIN per_det ON per_det.n_banda=bandas.n_banda
                JOIN atrxj ON atrxJ.ci_pd=per_det.ci
                GROUP BY bandas.n_banda , bandas.n_miembros , per_det.ci , atrxj.cod_b , atrxj.cod_s 
                HAVING COUNT(*)>1;');            
                return $query->result(); 
    }
                    /*SELECT DISTINCT Bandas.Nombre_B, Bandas.N_Banda, Bandas.N_Miembros
                    FROM (Bandas 
                    JOIN Per_Det ON Bandas.N_Banda=Per_Det.N_Banda
                    JOIN AtrxJ ON Per_Det.CI=AtrxJ.CI_PD)
                    GROUP BY Bandas.Nombre_B, Bandas.N_Banda, Bandas.N_Miembros, CI, AtrxJ.Cod_B, Cod_S
                    HAVING COUNT(*)>1;*/
}